#include"headfile.h"


void add(void)
{
    FILE * fp_stu = fopen("./document/student.txt","a");
    FILE * fp_user =fopen("./document/user.txt","a");
    char c,is;
    do
    {
        memNode * p = createNode(stu_num);
        if(NULL == p)
        {
            fclose(fp_stu);
            fclose(fp_user);
            return ;
        }
        char password[I + 1] = {0};
        fprintf(fp_stu,"%20s%20s%20d%20d\n",    //将输入的新学生加入到存储的学生文件中去
                p->mem.name,p->mem.sex,p->mem.age,p->mem.id);

        passwordInitial(p->mem.id,password,sizeof(password)/sizeof(password[0]));

        fprintf(fp_user,"%20d%20s%20s\n",    //将输入的新学生用户加入到存储的用户文件中去
                p->mem.id,p->mem.name,password);

        printf("是否要继续添加新学生 y/n:");
        while(1 == scanf("%c",&is))
        {
            if((is == 'y' || is == 'n') && (c = getchar()) == '\n') 
                break;
            else
            {
                while((c = getchar()) != '\n');
                printf("您输入的操作有误,请重新输入:");
            }
        }
    }while(is == 'y');

    fclose(fp_stu);
    fclose(fp_user);

    return ;
}